#include <algorithm>
#include <iostream>
#include "Deck.h"

using namespace std;

Deck::Deck() {
	populate();
}

Deck::~Deck()
{
	for(int i=0;i<cardDeck.size();++i)
	{
		delete cardDeck[i];
	}
	cardDeck.clear();
}

void Deck::populate(){
	for(int i=0; i<4; ++i) 
		for(int j=1; j<14; ++j) 
			cardDeck.push_back(new Card(i/*cardType*/, j/*cardNumber*/));//create a card from the enum card types
}
   
void Deck::shuffle() {
    random_shuffle(cardDeck.begin(), cardDeck.end());
}

void Deck::dealOneCard(Hand &hand) {
	if(cardDeck.size() > 0) {
		hand.add(cardDeck.back());
		cardDeck.pop_back();              
    } else 
		cout << "Can't deal cards, Deck is Empty";//print out error if there is no card left in the deck
}